var mysql = require('mysql');
var pool = mysql.createPool({
  host: 'localhost',
  port: 3306,
  user: 'root',
  password: 'hwd19981214',
  database: 'my_crm'
});

//创建连接池
const obj = {
  my_crm: (sql, arr) => {
    return new Promise((resolve, reject) => {
      pool.getConnection((err, conn) => {
        if (err) reject(err);
        else {
          conn.query(sql, arr, (err1, rows) => {
            if (err1) reject(err1);
            else resolve(rows);
          });
        }
        pool.releaseConnection(conn);
      });
    });
  }
}
module.exports = obj